package scm.server;

import java.util.Hashtable;

import scm.client.MailClient;
import scm.message.Message;

public class MailServer {
	private Hashtable<String, MailClient> clientList = null;
	
	
	public MailServer(){
		clientList = new Hashtable<String, MailClient>();
	}
	
		
	public int getCantidadMensaje(String nombre){
		return clientList.size();
	}
	
	public Message getSiguienteMensaje(String nombre){
		return null;
	}
	
	public void post(Message m){
		if (clientList.containsKey(m.getDestinatario())){
			MailClient client= null;
			client = clientList.get(m.getDestinatario());
			client.reciveMessage(m);
			System.out.println("Mail From:"+m.getSender()+" To:"+m.getDestinatario());
		}else
		{
			System.out.println("No existe este Cliente:"+m.getDestinatario());
		}
	}
	
	public void addClient(MailClient client){
		clientList.put(client.getName(), client);
	}
	
}
